<style scoped lang="scss">
.fans {
  .virtual_data {
      width: 100%;
      text-align: center;
      font-size: 1.6rem;
      padding: 1px 0 8px;
  }
  .p_vartual {
    color: #999;
    margin-top: 10px;
    padding: 0 5px;
    line-height: 15px;
  }
}
</style>
<template>
  <div class="fans padding-all-l">
    <!-- <div class="virtual_data" :color="$store.getters.getMasterColor">
       虚拟人数 
    </div> -->
    <van-cell-group>
      <van-field v-model="form.visit" label="浏览人数" maxlength="12" placeholder="请输入浏览人数" />
      <van-field v-model="form.order" label="订单记录数" maxlength="20" placeholder="请输入订单记录数" />
      <van-field v-show="itemShow" v-model="form.prize" maxlength="11" label="奖品记录数" placeholder="请输入奖品记录数" />
      <van-field v-show="commissionShow" v-model="form.comrecord" maxlength="11" label="佣金记录数" placeholder="请输入佣金记录数" />
      <!-- <van-field readonly v-show="modelShow" v-model="form.price" maxlength="11" label="订单价格" placeholder="请输入订单价格" />
      <van-field readonly v-show="itemShow" v-model="form.prize_id" maxlength="11" label="奖品id" placeholder="请输入奖品id" /> -->
    </van-cell-group>
    <div class="margT-l padding-lr">
      <van-button :color="$store.getters.getMasterColor" size="large" :loading="loading" block @click="submit">提交</van-button>
    </div>
    <p class="p_vartual">虚拟浏览人数填写多少就会在活动数据中加上多少，订单记录数、奖品记录数、佣金记录数]每次所加数量不会超过[虚拟管理]中的头像数</p>
  </div>
</template>

<script>
// @ is an alias to /src
import { Icon, Toast, CellGroup, Popup } from 'vant'
import {myMixins} from "@/assets/js/mixins.js"
export default {
  name: "virtual",
  mixins: [myMixins],
  components: {
    [Icon.name]: Icon,
    [CellGroup.name]: CellGroup,
    [Popup.name]: Popup,
  },
  data () {
    return {
      openid:'',
      fansInfo:{},
      virtualList:[],
      pageNo: 1,
      pageSize: 10,
      loading:false,
      form: {
        visit: null,
        order: null,
        prize: null,
        comrecord: null,
        price: null,
        prize_id: null
      },
      activityItem: {},
      itemShow: false,
      modelShow: true,
      commissionShow: false
    }
  },
  created() {
    this.getAvatarPage()
    this.getActivityItem()
  },
  mounted() {
    if (process.env.NODE_ENV == "production") {
      //线上环境
      this.openid = localStorage.getItem("OPENID") || "没获取到";
    } else {
      this.openid = this.$store.state.openid;
    }
  },
  methods: {
    getAvatarPage() {
      this.$request.getAvatarPage().then((res) => {
        this.virtualList = res.data.data;
        console.log(this.virtualList, 'virtualList123456');
      });
    }, 
    getActivityItem() {
      let params = {
        id: Number(this.$route.params.id),
      }
      this.$request.getActivityItem(params).then(res => {
        this.activityItem = res.data
        this.form.price = this.activityItem.val.price
        if(this.activityItem.prizes.length>0) {
          this.form.prize_id = this.activityItem.prizes[0].prize_id
        }
        // console.log(this.activityItem.prizes.length, this.activityItem.prizes[0].prize_id );
        if(this.activityItem.prizes.length > 0) {
          this.itemShow = true
        }
        if(this.activityItem.model == "scratchablelatex" || this.activityItem.model == "lottoActivity"  ) {
          this.modelShow = false
        }

        if(this.activityItem.model == "groupBuying" || this.activityItem.model == "envelopesTalk"  ) {
          this.commissionShow = true
        }
        
      })
    },
    submit() {
      console.log(11111);
      let params = {
        visit: this.form.visit,
        order: this.form.order,
        prize: this.form.prize,
        comrecord: this.form.comrecord,
        price: this.form.price,
        prize_id: this.form.prize_id,
        activity_id: Number(this.$route.params.id),
      }
      this.$request.getAvatarFansinsert(params).then(res => {
        this.form.visit = null
        this.form.order = null
        this.form.prize = null
        this.form.comrecord = null
        Toast('保存成功！')
      })
    } 
  }
};
</script>
